'use strict';

const Service = require('egg').Service;

class LoginService extends Service {
  async judge(options) {
    const { app } = this;
    const user = await app.mysql.get('user', { username: options.userName });
    if (!user) {
      const result = {};
      result.code = 500;
      result.msg = '此用户不存在';
      return result;
    }
    if (user.password != options.password) {
      const result = {};
      result.code = 304;
      result.msg = '密码不正确！';
      return result;
    }
    user.code = 200;
    user.msg = '登陆成功！';
    return user;
  }
}

module.exports = LoginService;
